<template>
    <div class='business' ref="businessRef" :class="{ isShow }">
        <MainContentPc class="main" :bg="businessBg">
            <div class="title">
                <div class="line"></div>
                <div class="text">业务概览</div>
                <div class="line"></div>
            </div>
            <div class="more-text">
                <span>公司聚焦豪华、超豪华汽车销售主业，布局新能源汽车综合服务产业，专注为客户提供高效、便捷、人车和谐的高品质出行服务。</span>
            </div>
            <div class="cards">
                <div class="card">
                    <div class="filter">
                        <div class="icon">
                            <img src="@/assets/images/business-icon1.png" alt="">
                        </div>
                        <div class="line"></div>
                        <div class="title">业务介绍</div>
                        <div class="text">
                            <span>汇聚全球豪华基因</span>
                            <span>&nbsp&nbsp&nbsp&nbsp&nbsp</span>
                            <span>引领和谐品质体验</span>
                        </div>
                        <div class="detail-btn">查看详情</div>
                    </div>
                </div>
                <div class="card">
                    <div class="filter">
                        <div class="icon">
                            <img src="@/assets/images/business-icon2.png" alt="">
                        </div>
                        <div class="line"></div>
                        <div class="title">业务介绍</div>
                        <div class="text">
                            <span>汇聚全球豪华基因</span>
                            <span>&nbsp&nbsp&nbsp&nbsp&nbsp</span>
                            <span>引领和谐品质体验</span>
                        </div>
                        <div class="detail-btn">查看详情</div>
                    </div>
                </div>
            </div>
        </MainContentPc>
    </div>
</template>

<script setup lang="ts">
import { useIntersectionObserver } from '@vueuse/core'
import businessBg from '@/assets/images/business-bg.jpg'
const businessRef:Ref<HTMLElement|null> = ref(null)
const isShow:Ref<boolean> = ref(false)
onMounted(() => {
    useIntersectionObserver(
        businessRef.value,
        ([{ intersectionRatio}]) => {
            if(intersectionRatio > 0.5)isShow.value = true
        },
        {
            threshold: [0.5],
        }
    )
})
</script>


<style lang="scss" scoped>
.business{
    height: 1000px;
    &.isShow{
        .title,
        .more-text,
        .cards{
            animation:showDom 1s;
            animation-fill-mode:forwards;
        }
    }
    .title{
        opacity:0;
        animation-delay:200ms;
        padding-top: 70px;
        justify-content: center;
        display: flex;
        >.line{
            flex:1;
            border-bottom: 1px solid #fff;
        }
        >.text{
            color: #fff;
            width:200px;
            margin: 0 3%;
            font-size: 36px;
            font-weight: normal;
            color: #fff;
            height: 120px;
            line-height: 120px;
            border-bottom: 1px solid #fff;
            text-align: center;
        }
    }
    .more-text{
        opacity:0;
        animation-delay:500ms;
        text-align: center;
        font-size: 16px;
        color: #fff;
        margin-top: 40px;
    }
    .cards{
        opacity:0;
        animation-delay:700ms;
        display: flex;
        justify-content: center;
        margin-top: 80px;
        .card {
            cursor: pointer;
            background-size: cover;
            background-position: center;
            .filter{
                background-color:transparent;
                padding-top: 150px;
                &:hover{
                    background-color: #5e5e5e7b;
                }
                height: 516px;
                width: 450px;
                text-align: center;
                color: #fff;
                align-items: center;
                transition: all .5s;
                .icon{
                    height: 50px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    img{
                        width: 80px;
                    }
                }
                .line{
                    height: 2px;
                    margin:0 auto;
                    border-radius: 20%;
                    margin-top: 14px;
                    transition: all 300ms ease;
                    opacity: 1;
                    background-color: #fff;
                    width: 30px;
                }
                .title{
                    padding-top: 40px;
                    transition: all 500ms ease;
                    font-size: 24px;
                }
                .text{
                    padding-top: 50px;
                    transition: all 600ms ease;
                    font-size: 12px;
                    color: #ffffffb6;
                }
                .detail-btn{
                    width: 122px;
                    height: 30px;
                    text-align: center;
                    line-height: 30px;
                    border: 1px solid #fff;
                    font-size: 12px;
                    color: #fff;
                    margin: 0 auto;
                    margin-top: 20px;
                    &:hover{
                        border:1px solid #ecb86b;
                        color:#ecb86b;
                    }
                }
            }
            &:nth-child(1){
                background-image: url('@/assets/images/business-card1.jpg');
            }
            &:nth-child(2){
                background-image: url('@/assets/images/business-card2.jpg');
                .icon img{
                    width:50px
                }
            }
            &:hover{
                .icon{
                    opacity: 0;
                    transform-style: preserve-3d;
                    animation: flip 500ms;
                    animation-delay:200ms;
                    animation-fill-mode:forwards;
                }
                .line{
                    width: 0px;
                }
                .title{
                    padding-top: 5px;
                }
                .text{
                    padding-top:15px
                }
            }
        }
    }
    // 3d Y轴 翻转 先看不到再转出来
    @keyframes flip {
        0%{
            opacity: 1;
            transform: rotateY(-90deg);
        }
        80%{
            opacity: 1;
            transform: rotateY(10deg);
        }
        100%{
            opacity: 1;
            transform: rotateY(0);
        }
    }
    @keyframes showDom {
        0%{
            opacity: 0;
            transform: translateY(50px);
        }
        100%{
            opacity: 1;
            transform: translateY(0);
        }
    }
}
</style>